#INCLUDE "PROTHEUS.CH"
#INCLUDE "APWEBEX.CH"

User Function fswpva04()
local chtml:= ""
Local campo := ""
private oObj:= {}

WEB EXTENDED INIT cHtml
	
If !Empty(HttpSession->aUser) .and. !Empty(HttpSession->aComan)
	
	If !Empty(HTTPPOST->CCODIGO)
		oObj := WSFSWWSS01():New()
		oObj:CPRODUCTCODE := HTTPPOST->CCODIGO

		If oObj:GETPRODUCTNAME()
		
			//Verefica se existe valor na lista
			If !Empty(HttpSession->aLista)
				//posiciona no ultimo converte para numerico soma +1 e converte para string
				campo := str((Val(HttpSession->aLista[Len(HttpSession->aLista)][4])+1),2)
			else
				campo:= "1"
			EndIf
			
			
			aAdd(HttpSession->aLista,{1,;
					oObj:OWSGETPRODUCTNAMERESULT:OWSPDTARRAY[1]:CB1_DESC,;
					oObj:OWSGETPRODUCTNAMERESULT:OWSPDTARRAY[1]:NB1_PRV1,;
					campo,;
					2})
		EndIF

		Return cHtml := RedirPage( "u_fswpva03.apw" )
	Else
		Return cHtml := RedirPage( "u_fswpva03.apw" )
	EndIf

ElseIF !Empty(HttpSession->aUser) .and. Empty(HttpSession->aComan)
	Return cHtml := RedirPage( "u_fswpva02.apw" )
Else
	Return cHtml := RedirPage( "u_fswpva01.apw" )
EndIf

WEB EXTENDED END

Return chtml